<!--
 * @Description: .
 * @Version: 2.0
 * @Autor: zhangjx
 * @Date: 2023-05-26 14:59:23
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2023-10-11 20:43:00
-->
<template>
	<BaseContainer>
		<div class="w-100">
			<aplid-base-crud ref="crud" v-bind="baseConfig">
        <template v-slot:dictName="{row}">
            <el-link type="primary" @click="handleOperate(row)">{{row.dictName}}</el-link>
        </template>
				<template v-slot:viewDialog="{ row, show }">
					<dictItem @refresh="handleRefresh" :api="baseConfig.api" v-if="show" :nowRowData="row"> </dictItem>
				</template>
				<template v-slot:addDialog="{ row, show }">
					<tabForm @refresh="handleRefresh" :api="baseConfig.api" v-if="show" :nowRowData="row"> </tabForm>
				</template>
				<template v-slot:editDialog="{ row, show }">
					<tabForm @refresh="handleRefresh" :api="baseConfig.api" v-if="show" :nowRowData="row"> </tabForm>
				</template>
			</aplid-base-crud>
		</div>
	</BaseContainer>
</template>

<script setup lang="ts">
import { baseConfig } from './config'
import tabForm from './tabForm.vue'
import dictItem from './dictItem/index.vue'
import { useCrudStore } from '@/stores/crud'
const { saveDictForm } = useCrudStore()


const crud = ref(null)

const handleRefresh = () => {
	nextTick(() => {
		crud.value?.refreshChange({}, true)
	})
}

const handleOperate = (row)=> {
  saveDictForm(row,false).then(()=> {
    crud.value?.handleOperate('view', row, '字典项详情')
  })
}
</script>

<style scoped></style>
